﻿Imports System
Imports System.IO
Imports System.Data.SqlServerCe
Imports System.Drawing
Imports System.Collections
Imports System.Windows.Forms
Imports System.Data
Imports System.Data.Common

Module ComboService

    Sub refreshComboCouponNo(ByVal cbo As System.Windows.Forms.ComboBox)
        cbo.Items.Clear()

        Dim dtResult As New DataTable
        dtResult = findCouponNoByGroup()

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows
                cbo.Items.Add(dataRow.Item("COUPON_CODE").ToString)
            Next
        End If
    End Sub

    Sub refreshComboCouponCreateDate(ByVal cbo As System.Windows.Forms.ComboBox)
        cbo.Items.Clear()

        Dim dtResult As New DataTable
        dtResult = findCouponCreateDateByGroup()

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows
                cbo.Items.Add(dataRow.Item("DATE_ADD").ToString)
            Next
        End If
    End Sub

    Sub refreshComboAcceptRejectWeldlogUpdateDate(ByVal cbo As System.Windows.Forms.ComboBox)
        cbo.Items.Clear()

        Dim dtResult As New DataTable
        dtResult = findAcceptRejectWeldlogUpdateDateByGroup()

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows
                cbo.Items.Add(dataRow.Item("DATE_UPDATE").ToString)
            Next
        End If
    End Sub

    Sub loadZone(ByVal cbo As System.Windows.Forms.ComboBox)
        'cbo.Items.Clear()

        Dim dtResult As New DataTable
        dtResult = findZones(Nothing, _PROJECT_ID)

        cbo.ValueMember = "ZONE_ID"
        cbo.DisplayMember = "ZONE"
        cbo.DataSource = dtResult
    End Sub

    Sub loadCouponSystemForCbo(ByVal cbo As System.Windows.Forms.ComboBox, ByVal couponBarcode As String)
        'cbo.Items.Clear()

        Dim dtResult As New DataTable
        dtResult = findCouponSystems(couponBarcode)

        cbo.ValueMember = "SYSTEM_TYPE_ID"
        cbo.DisplayMember = "SYSTEM_TYPE_NAME"
        cbo.DataSource = dtResult
        'If dtResult.Rows.Count > 0 Then
        'For Each dataRow As DataRow In dtResult.Rows
        'cbo.Items.Add(DataRow.Item("SYSTEM_TYPE_NAME").ToString)
        'Next
        'End If
    End Sub

    Sub loadMaterialForCbo(ByVal cbo As System.Windows.Forms.ComboBox)
        cbo.Items.Clear()

        Dim dtResult As New DataTable
        dtResult = findMaterials()

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows
                cbo.Items.Add(dataRow.Item("MATERIAL").ToString)
            Next
        End If
    End Sub

    Sub loadWeldMachineForCbo(ByVal cbo As System.Windows.Forms.ComboBox)
        cbo.Items.Clear()

        Dim dtResult As New DataTable
        dtResult = findWeldMachines(_PROJECT_ID, Nothing)

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows
                cbo.Items.Add(dataRow.Item("SERIAL_NUMBER").ToString)
            Next
        End If
    End Sub

    Sub loadRejectReason(ByVal cbo As System.Windows.Forms.ComboBox, ByVal cbo2 As System.Windows.Forms.ComboBox)
        cbo.Items.Clear()
        If (cbo2 IsNot Nothing) Then
            cbo2.Items.Clear()
        End If

        Dim dtResult As New DataTable
        dtResult = findRejectReason()

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows
                cbo.Items.Add(dataRow.Item("REASON").ToString)
                If (cbo2 IsNot Nothing) Then
                    cbo2.Items.Add(dataRow.Item("REASON").ToString)
                End If
            Next
        End If
    End Sub

    Sub loadZone(ByVal cbo As System.Windows.Forms.ComboBox, ByVal cbo2 As System.Windows.Forms.ComboBox)
        cbo.Items.Clear()
        If (cbo2 IsNot Nothing) Then
            cbo2.Items.Clear()
        End If

        Dim dtResult As New DataTable
        dtResult = findZones(Nothing, _PROJECT_ID)

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows
                cbo.Items.Add(dataRow.Item("ZONE").ToString)
                If (cbo2 IsNot Nothing) Then
                    cbo2.Items.Add(dataRow.Item("ZONE").ToString)
                End If
            Next
        End If
    End Sub

    Sub loadHeatNoForCbo(ByVal cbo As System.Windows.Forms.ComboBox, ByVal cbo2 As System.Windows.Forms.ComboBox)
        cbo.Items.Clear()
        If (cbo2 IsNot Nothing) Then
            cbo2.Items.Clear()
        End If

        Dim dtResult As New DataTable
        dtResult = findHeatNos(_PROJECT_ID, Nothing)

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows
                cbo.Items.Add(dataRow.Item("HEAT_NUMBER_NAME").ToString)
                If (cbo2 IsNot Nothing) Then
                    cbo2.Items.Add(dataRow.Item("HEAT_NUMBER_NAME").ToString)
                End If
            Next
        End If
    End Sub

    Sub loadSystemForCbo(ByVal cbo As System.Windows.Forms.ComboBox)
        cbo.Items.Clear()

        Dim dtResult As New DataTable
        dtResult = findSystemTypes(_PROJECT_ID, Nothing)

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows
                cbo.Items.Add(dataRow.Item("SYSTEM_TYPE_NAME").ToString)
            Next
        End If
    End Sub

    Sub loadWeldSizeForCbo(ByVal welderId As String, ByVal cbo As System.Windows.Forms.ComboBox)
        cbo.Items.Clear()

        Dim dtResult As New DataTable
        dtResult = findWeldSize(welderId)

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows
                cbo.Items.Add(dataRow.Item("SIZE").ToString)
            Next
        End If
    End Sub

    Sub loadSizeForCbo(ByVal projectId As String, ByVal cbo As System.Windows.Forms.ComboBox, ByVal cbo2 As System.Windows.Forms.ComboBox)
        cbo.Items.Clear()
        If (cbo2 IsNot Nothing) Then
            cbo2.Items.Clear()
        End If

        Dim dtResult As New DataTable
        dtResult = findGroupBySizes(projectId)

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows
                cbo.Items.Add(dataRow.Item("SIZE").ToString)
                If (cbo2 IsNot Nothing) Then
                    cbo2.Items.Add(dataRow.Item("SIZE").ToString)
                End If
            Next
        End If
    End Sub

    Sub loadThicknessForCbo(ByVal projectId As String, ByVal cbo As System.Windows.Forms.ComboBox, ByVal cbo2 As System.Windows.Forms.ComboBox)
        cbo.Items.Clear()
        If (cbo2 IsNot Nothing) Then
            cbo2.Items.Clear()
        End If

        Dim dtResult As New DataTable
        dtResult = findGroupByThickness(projectId)

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows
                cbo.Items.Add(dataRow.Item("THICKNESS").ToString)
                If (cbo2 IsNot Nothing) Then
                    cbo2.Items.Add(dataRow.Item("THICKNESS").ToString)
                End If
            Next
        End If
    End Sub

    Sub loadJointTypeForCbo(ByVal cbo As System.Windows.Forms.ComboBox, ByVal cbo2 As System.Windows.Forms.ComboBox)
        cbo.Items.Clear()
        If (cbo2 IsNot Nothing) Then
            cbo2.Items.Clear()
        End If

        Dim dtResult As New DataTable
        dtResult = findJointTypes(Nothing)

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows
                cbo.Items.Add(dataRow.Item("JOINT_TYPE_NAME").ToString)
                If (cbo2 IsNot Nothing) Then
                    cbo2.Items.Add(dataRow.Item("JOINT_TYPE_NAME").ToString)
                End If
            Next
        End If
    End Sub

End Module